home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr48
/
pas_0593.zip
/
GETSTRNG.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-30
|
2KB
|
80 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 319 of 410
From : Nico Keirsmakers 2:292/804.3 09 May 93 11:41
To : Steven O'neal 1:3800/22.0
Subj : Line Fields
────────────────────────────────────────────────────────────────────────────────
Hello Steven!
30 Apr 93, Steven O'neal writes to All:
SO> :_________________________________________________________________________
SO> _ ___: / \
SO> how can i make the users keyboard lock from typeing over the colon, or
SO> keep retyping the last char.. thanx for any help!!
Here's a routine I made some time ago to do this :}
Function GetString(cx,cy : integer; Prompt : String; MaxLen : Integer;OKSet :
charset):string;
const
BS = ^H;
CR = ^M;
ConSet : CharSet = [BS,CR];
var
TStr : string;
TLen,X,i : Integer;
Ch : Char;
begin
{$I-} { turn off I/O checking }
TStr := '';
TLen := 0;
Print(cx,cy,Prompt);
X := cx + Length(Prompt);
For i := x to (x + Maxlen - 1) do
Print(i,cy,'_');
Print(x,cy,Default);
OKSet := OKSet + ConSet;
repeat
Gotoxy(x,cy);
repeat
ch := readkey
until Ch in OKSet;
if Ch = BS then begin
if TLen > 0 then begin
TLen := TLen - 1;
X := X - 1;
GoToXY(X,cy); Write('_');
end
end
else if (Ch <> CR) and (TLen < MaxLen) then begin
Write(Ch);
TLen := TLen + 1;
TStr[TLen] := Ch;
X := X + 1;
end
until Ch = CR;
If Tlen > 0
Then Begin
TStr[0] := chr(Tlen);
Getstring := TStr
End
Else Getstring := Default;
{$I+}
end;
Use it like this :
Default := 'BELGIUM';
Country := Getstring(16, 5,'Enter country : ',25,['a'..'z','A'..'Z',' ']);
Output is like this :
Enter country : BELGIUM___________________
^\
Cursor will be here.